import app from "../app";
import { Effect_item } from "../model/fight/skill/SK_active";
import { EffectType } from "../shared/interface";

/**
 * 命名规则
 * 效果描述
 * 加成组成
 * -概率
 */
export enum cfg_effectKey {
    永久增加最大生命值_1,
    恢复目标生命值_范围,
    临时提升力量_1,
    普攻_对目标造成物理伤害_1,
    对目标造成魔法伤害_1,
    沉默,
    提升物理吸血,
    提升攻击速度,
    提升最大生命,
    提升生命恢复速度,
    屏障,
    召唤永久单位_1,
    召唤永久单位_2,
    对目标造成魔法伤害_高范围,
    对目标造成魔法伤害_单体高伤害,
    对目标造成物理伤害_基于护甲,
    对目标造成物理伤害_单体高伤害,
    对目标造成物理伤害_高范围,
    恢复目标生命值_单体,
    提升物理防御,
    对目标造成真实伤害_高范围,
    召唤永久单位_地狱九头蛇_伪,
    召唤永久单位_地狱九头蛇_分裂体,
    增加金币
}
/**
 * 效果库
 */
let effectMap: Map<cfg_effectKey, Effect_item> = new Map();
export function _getEffect(key: cfg_effectKey) {
    return effectMap.get(key);
}
// 触发后将增加单位屏障生命
effectMap.set(cfg_effectKey.屏障, {
    rang: 1,
    effect: EffectType.屏障,
    // dice: 30,
    data: {
        input: [{ read: "", val: 3, type: "+", leve_type: '+', leve_sup: 1 }],
        formula: "0",
    },
    create: function (score: number) {
        this.data.input[0].val = app.generateRandom(1, app.getAttVaule('Hp_Max') * score);
        this.data.input[0].leve_sup = app.generateRandom(1, 20);
    }
})
// 概率触发 触发后将永久增加生命值上限
effectMap.set(cfg_effectKey.永久增加最大生命值_1, {
    rang: 1,
    effect: EffectType.永久增加最大生命值,
    // //hitType: EffectHitType.永久增幅_生命提升,
    dice: 30,
    data: {
        input: [{ read: "", val: 3, type: "+", leve_type: '+', leve_sup: 0.01 }],
        formula: "0",
    },
    create: function (score: number) {
        this.data.input[0].val = app.generateRandom(1, score / app.getAttVaule('Hp_Max'), score, 300) / 100;
        // this.data.input[0].leve_sup = this.data.input[0].val * 0.01;
        this.dice = app.generateRandom(1, 30, score / 100, 30);
    }
})

/**
 * 范围治疗效果
 * 固定值 + 技能基数
 */
effectMap.set(cfg_effectKey.恢复目标生命值_范围, {
    rang: 5,
    effect: EffectType.恢复目标生命值,
    //hitType: EffectHitType.治疗,
    data: {
        input: [
            { read: '', val: 100, type: '+', leve_type: '+', leve_sup: 10 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(1, 5);
        this.data.input[0].val = score * app.getAttVaule('Hp_Max') / this.rang;
    }
})
effectMap.set(cfg_effectKey.恢复目标生命值_单体, {
    rang: 1,
    effect: EffectType.恢复目标生命值,
    //hitType: EffectHitType.治疗,
    data: {
        input: [
            { read: '', val: 100, type: '+', leve_type: '+', leve_sup: 20 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].val = score * app.getAttVaule('Hp_Max');
    }
})

effectMap.set(cfg_effectKey.临时提升力量_1, {
    rang: 0,
    effect: EffectType.临时提升目标力量,
    //hitType: EffectHitType.临时增幅_力量提升,
    data: {
        input: [
            { read: '', val: 100, type: '+', leve_type: '+', leve_sup: 1 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(1, 5, score / 100);
        this.data.input[0].val = app.generateRandom(1, 100, score / app.getAttVaule('a'), 1000);
        this.data.input[0].leve_sup = app.generateRandom(1, 100, score / app.getAttVaule('a'));
    }
})

effectMap.set(cfg_effectKey.普攻_对目标造成物理伤害_1, {
    rang: 1,
    effect: EffectType.对目标造成物理伤害,
    //hitType: EffectHitType.普通攻击,
    data: {
        input: [
            { read: 'me.read_key("物理攻击")', val: 1, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        // this.rang = app.generateRandom(1, 2, score / 1000, 3);
        // const attackV = app.getAttVaule('Physical_Attack_max') + app.getAttVaule('Physical_Attack_min')
        this.data.input[0].leve_sup = app.generateRandom(1, score, 0, 2000) / 1000;
    }
})
effectMap.set(cfg_effectKey.对目标造成物理伤害_基于护甲, {
    rang: 1,
    effect: EffectType.对目标造成物理伤害,
    data: {
        input: [
            { read: 'me.read_key("物理防御")', val: 1, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        // this.rang = app.generateRandom(1, 2, score / 1000, 3);
        // const attackV = app.getAttVaule('Physical_Attack_max') + app.getAttVaule('Physical_Attack_min')
        this.data.input[0].val = app.generateRandom(100, score, 0, 2000) / 1000;
        this.data.input[0].leve_sup = app.generateRandom(1, score, 0, 100) / 1000;
    }
})


effectMap.set(cfg_effectKey.对目标造成魔法伤害_1, {
    rang: 1,
    effect: EffectType.对目标造成魔法伤害,
    //hitType: EffectHitType.普通攻击,
    data: {
        input: [
            { read: 'me.read_key("魔法攻击")', val: 1, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = Math.floor(app.generateRandom(1000, 5000, score / 1000, 10000) / 1000);
        this.data.input[0].leve_sup = app.generateRandom(1, score) / 1000;
    }
})
effectMap.set(cfg_effectKey.对目标造成魔法伤害_高范围, {
    rang: 1,
    effect: EffectType.对目标造成魔法伤害,
    //hitType: EffectHitType.普通攻击,
    data: {
        input: [
            { read: 'me.read_key("魔法攻击")', val: 0.8, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = Math.floor(app.generateRandom(3, 10, score / 100, 100));
        this.data.input[0].leve_sup = app.generateRandom(1, score) / 1000;
    }
})
effectMap.set(cfg_effectKey.对目标造成魔法伤害_单体高伤害, {
    rang: 1,
    effect: EffectType.对目标造成魔法伤害,
    //hitType: EffectHitType.普通攻击,
    data: {
        input: [
            { read: 'me.read_key("魔法攻击")', val: 0.8, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].val = app.generateRandom(100, 200, score,1000) / 100
        this.data.input[0].leve_sup = app.generateRandom(1, score) / 70;
    }
})
effectMap.set(cfg_effectKey.对目标造成物理伤害_单体高伤害, {
    rang: 1,
    effect: EffectType.对目标造成物理伤害,
    //hitType: EffectHitType.普通攻击,
    data: {
        input: [
            { read: 'me.read_key("物理攻击")', val: 0.8, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].val = app.generateRandom(100, 200, score,8000) / 100
        this.data.input[0].leve_sup = app.generateRandom(1, score) / 1000;
    }
})
effectMap.set(cfg_effectKey.对目标造成物理伤害_高范围, {
    rang: 1,
    effect: EffectType.对目标造成物理伤害,
    //hitType: EffectHitType.普通攻击,
    data: {
        input: [
            { read: 'me.read_key("物理攻击")', val: 0.75, type: '*', leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = Math.floor(app.generateRandom(3, 10, score / 100, 80));
        this.data.input[0].leve_sup = app.generateRandom(1, score) / 100;
    }
})


// 沉默一定时间
effectMap.set(cfg_effectKey.沉默, {
    rang: 1,
    effect: EffectType.沉默单体,
    //hitType: EffectHitType.沉默,
    data: {
        input: [
            // 沉默时间-s
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 0 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        // this.rang = app.generateRandom(1, 1,score);
        this.data.input[0].val = app.generateRandom(1, 10, score,120);
    }
})
effectMap.set(cfg_effectKey.提升物理吸血, {
    rang: 1,
    effect: EffectType.buff_提升物理吸血,
    data: {
        input: [
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        time:60,
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(1, score / app.getAttVaule('Physical_Ls'), 0, 10);
        this.data.input[0].val = app.generateRandom(1, score / app.getAttVaule('Physical_Ls') * 100, 0, 1000) / 100;
    }
})

effectMap.set(cfg_effectKey.提升攻击速度, {
    rang: 1,
    effect: EffectType.buff_提升攻击速度,
    data: {
        input: [
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        time:60,
        formula: '0'
    },
    create: function (score: number) {
        // this.rang = app.generateRandom(1, score / app.getAttVaule('Attack_Speed'), 0, 10);
        this.data.input[0].val = app.generateRandom(50, score / app.getAttVaule('Attack_Speed'), 0, 150) / 100;
    }
})
effectMap.set(cfg_effectKey.提升生命恢复速度, {
    rang: 1,
    effect: EffectType.buff_提升生命恢复,
    data: {
        input: [
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        time:60,
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(1, 4, score / app.getAttVaule('Hp_res'), 10);
        this.data.input[0].val = app.generateRandom(1, score / app.getAttVaule('Hp_res') * 100, 0, 100) / 100;
    }
})
effectMap.set(cfg_effectKey.提升物理防御, {
    rang: 1,
    effect: EffectType.buff_提升物理防御,
    data: {
        input: [
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        time:60,
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(1, 4, score / app.getAttVaule('Physical_defense'), 10);
        this.data.input[0].val = score / app.getAttVaule('Physical_defense');
    }
})
effectMap.set(cfg_effectKey.对目标造成真实伤害_高范围, {
    rang: 1,
    effect: EffectType.真实伤害,
    data: {
        input: [
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 10 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(5, 10);
        this.data.input[0].val = score;
    }
})

effectMap.set(cfg_effectKey.提升最大生命, {
    rang: 1,
    effect: EffectType.buff_提升最大生命,
    data: {
        input: [
            { read: "", val: 1, type: "+", leve_type: '+', leve_sup: 1.5 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.rang = app.generateRandom(1, score / app.getAttVaule('Hp_Max'));
        this.data.input[0].val = app.generateRandom(1, score / app.getAttVaule('Hp_Max'));
        this.data.input[0].leve_sup = app.generateRandom(1, this.data.input[0].val);
    }
})
effectMap.set(cfg_effectKey.召唤永久单位_1, {
    rang: 1,
    effect: EffectType.召唤永久单位,
    //hitType: EffectHitType.召唤永久单位,
    data: {
        create_id: '1',
        input: [
            // 额外附加评分
            { read: 'me.read_key("无")', val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].leve_sup = app.generateRandom(1, score);
    }
})
effectMap.set(cfg_effectKey.召唤永久单位_2, {
    rang: 1,
    effect: EffectType.召唤永久单位,
    //hitType: EffectHitType.召唤永久单位,
    data: {
        create_id: '2',
        input: [
            // 召唤全属性增幅
            { read: 'me.read_key("无")', val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].leve_sup = app.generateRandom(1, score);
    }
})
effectMap.set(cfg_effectKey.召唤永久单位_地狱九头蛇_伪, {
    rang: 1,
    effect: EffectType.召唤永久单位,
    //hitType: EffectHitType.召唤永久单位,
    data: {
        create_id: '4',
        input: [
            // 召唤全属性增幅
            { read: 'me.read_key("无")', val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].leve_sup = app.generateRandom(1, score);
    }
})
effectMap.set(cfg_effectKey.召唤永久单位_地狱九头蛇_分裂体, {
    rang: 1,
    effect: EffectType.召唤永久单位,
    //hitType: EffectHitType.召唤永久单位,
    data: {
        create_id: '5',
        input: [
            // 召唤全属性增幅
            { read: 'me.read_key("无")', val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].leve_sup = app.generateRandom(1, score);
    }
})
effectMap.set(cfg_effectKey.增加金币, {
    rang: 1,
    effect: EffectType.增加金币,
    data: {
        input: [
            { read: 'me.read_key("无")', val: 1, type: "+", leve_type: '+', leve_sup: 0.01 },
        ],
        formula: '0'
    },
    create: function (score: number) {
        this.data.input[0].val = app.generateRandom(1, 6);
    }
})
